home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-14 | 4.5 KB | 150 lines | [TEXT/MPCC] |
- // This is based on the sample code on the QuickTime 1.5 CD ROM
- //
- // sample to show how to do searches with text media, and how to use
- // a simple text proc to get the text (without the style info) out and
- // to display it in a window.
- //
- // Copyright: © 1992-4 by Apple Computer, Inc.
- //
- // Modifications by Nick Thompson, 16 May 1994
- // 5/16/94 nt added text media stuff, repeat text in box below movie, uses TextBox
- // 5/17/94 nt implement find dialog
- // 5/31/94 nt implement textedit stuff to allow editing of the text track
- // 6/1/94 nt clean up textedit stuff and allow user to edit the text track
- // 10/8/94 nt support for styled text, bug fixes
- //
- // to do:
- // fix up cut and paste for text edit commands
- // TE edit menu
-
-
- #ifndef _TEXTMEDIAEXAMPLE_
- #define _TEXTMEDIAEXAMPLE_
-
- #define HiWrd(aLong) (((aLong) >> 16) & 0xFFFF)
- #define LoWrd(aLong) ((aLong) & 0xFFFF)
-
-
- //---------------------------------------------------------------------------
- // define a record to hold the information we need for each movie window.
- // The movie can be gotten from the movieController, and we need the TE and
- // control stuff for the edit area
- //---------------------------------------------------------------------------
-
- typedef struct {
- MovieController myController ;
- TEHandle myTEH ;
- ControlHandle myFindButton ; // this is the find button for this window
- ControlHandle myUpdateButton ; // lets the user update the text they just typed in
- Boolean myMovieIsActive ; // either the movie is or the te field is.
- Boolean myTextHasBeenModified ; // did the user change the text for the track
- } DocumentRecord, *DocumentPtr, **DocumentHandle ;
-
- //---------------------------------------------------------------------------
-
-
- extern const RGBColor kWindowBGColor ; // grays made the caret yellow, ughh, need to investigate this
- extern const RGBColor kRGBBlack ;
- extern const RGBColor kRGBGray ;
- extern const RGBColor kRGBWhite ;
- extern const short kSlopMargin ;
- extern const Rect kDefaultWinRect ;
-
-
- //---------------------------------------------------------------------
- // items in the find dialog
- //
- // This dialog is posted to allow the user to search for text in the
- // movie's text track
- //---------------------------------------------------------------------
-
- enum {
- diOK = 1,
- diCancel,
- diTextBox,
- diTextTitle,
- diBackwardsCheckBox,
- diWrapCheckBox
- } ;
-
-
- // make these globals, they contain state info for the find dialog
-
- extern Boolean gDlgSearchBack ;
- extern Boolean gDlgSearchWrap ;
- extern Str255 gDlgSearchText ;
-
- //---------------------------------------------------------------------
- //
- // menus and items...
-
- enum {
- mApple = 128,
- mFile,
- mEdit
- } ;
-
- enum {
- iAbout = 1
- } ;
- enum {
- iOpen = 1,
- iClose,
- iUnused1,
- iSaveAs = 4,
- iUnused2,
- iQuit
-
- } ;
-
- enum {
- iUndo = 1,
- iCut = 3,
- iCopy,
- iPaste,
- iClear,
- iSelectAll = 8
- } ;
-
- //---------------------------------------------------------------------
-
- DocumentHandle CreateDocumentHandle( WindowPtr aWindow ) ;
- WindowPtr CreateMovieWindow( Rect *aRect, Str255 theTitle ) ;
- MovieController SetUpMovieWindowWithController( WindowPtr aWindow, Movie aMovie ) ;
- OSErr SetMovieTextHandler( WindowPtr aWindow ) ;
- OSErr AddTEAndControl( WindowPtr aWindow ) ;
- void DoCreateMovieWindow( Movie aMovie) ;
- void DoDestroyMovieWindow( WindowPtr aWindow ) ;
- void DoUpdateText( WindowPtr whichWindow, Point theMouse, ControlHandle aControl ) ;
- void HandleContentClick( WindowPtr whichWindow, EventRecord *theEvent ) ;
- void MyDoIdle( WindowPtr whichWindow ) ;
- void DoActivateWindow( WindowPtr whichWindow, Boolean becomingActive) ;
- void DoSelectActive( WindowPtr whichWindow ) ;
- void AdornWindow( WindowPtr whichWindow, const RGBColor *adornerColor ) ;
- void DoUpdateWindow( WindowPtr whichWindow ) ;
- void MainEventLoop( void ) ;
- Boolean IsAppWindow(WindowPtr window) ;
- void DoFindDialog( WindowPtr theMovieWindow, Point theMouse, ControlHandle aControl ) ;
- void DoSearchForStringInMovieWindow( WindowPtr theMovieWindow,
- Str255 SearchText,
- Boolean searchBack,
- Boolean searchWrap) ;
- void AdjustMenus( void ) ;
- void HandleKeyPress(EventRecord *event) ;
- void HandleMenuCommand(long menuResult) ;
- void InitMac( void ) ;
- void DoDrawCurrentText( WindowPtr theWindow ) ;
-
- pascal OSErr MyTextProc( Handle thisText,
- Movie thisMovie,
- short *displayFlag,
- long refcon) ; // contains a ref to the window for this movie
- void main (void) ;
-
-
- // command handlers
-
- OSErr HandlePrintDoc( FSSpec *myFSS ) ;
- OSErr HandleOpenDoc( FSSpec *myFSS ) ;
-
- #endif